45/* Layout */
//
const Layout = () => import("@/layout")

import Vue from "vue"
import Router from "vue-router"

Vue.use(Router)

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
 roles: ['admin','editor']    control the page roles (you can set multiple roles)
 title: 'title'               the name show in sidebar and breadcrumb (recommend set)
 icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
 breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
 activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
 }
 */

import BusinessRouter from "@/router/BusinessRouter"

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [{
  path: "/showContent",
  name: "showContent",
  component: () => import("@/views/business/page/manager/health/content/frame/ShowContent.vue"),
  meta: { title: "内容展示", icon: "dashboard" }
}, // ====================  框架界面  ====================
{
  path: "/dc/admin/setting",
  component: () => import("@/views/frame/page/setting/index"),
  meta: { title: "系统设置", icon: "dashboard" },
  hidden: true
}, {
  path: "/dc/admin/login",
  component: () => import("@/views/frame/page/login/index"),
  meta: { title: "用户登录", icon: "dashboard" },
  hidden: true
}, {
  path: "/dc/admin/skip",
  component: () => import("@/views/frame/page/skip"),
  meta: { title: "跳转中", icon: "dashboard" },
  hidden: true
}, {
  path: "/404",
  component: () => import("@/views/frame/page/error/404"),
  meta: { title: "404 - 页面未找到", icon: "dashboard" },
  hidden: true
},

// ====================  layout布局的界面  ====================
{
  path: "/",
  component: Layout,
  redirect: "/base/home",
  children: [// ====================  基础界面 - 主页  ====================
    {
      path: "/base/home",
      component: () => import("@/views/frame/page/home"),
      meta: { title: "系统首页", icon: "dashboard" }
    }, // ====================  基础界面 - 示例界面  ====================
    {
      path: "demo/list",
      name: "list",
      component: () => import("@/views/demo/list"),
      meta: { title: "列表页示例", icon: "dashboard" },
      hidden: true
    }, {
      path: "/demo/info",
      name: "info",
      component: () => import("@/views/demo/info"),
      meta: { title: "信息页页示例", icon: "dashboard" },
      hidden: true
    }, {
      path: "/demo/report",
      name: "report",
      component: () => import("@/views/demo/report"),
      meta: { title: "报表页示例", icon: "dashboard" },
      hidden: true
    }, {
      path: "/demo/board",
      name: "board",
      component: () => import("@/views/demo/board"),
      meta: { title: "看板页示例", icon: "dashboard" },
      hidden: true
    }, { ...BusinessRouter }, //  ====================  门店管理 - 门店字典 - 库存管理  ====================
    {
      name: "position",
      meta: { title: "药库", icon: "dashboard" },
      path: "/business/manager/clinic/inventory/inventory/position/:viewMode/:mode",
      component: () => import("@/views/business/page/manager/clinic/inventory/inventory/Position"),
      hidden: true,
      props: true
    }, {
      name: "inventory",
      meta: { title: "库存", icon: "dashboard" },
      path: "/business/manager/clinic/inventory/inventory/inventory/:viewMode/:mode",
      component: () => import("@/views/business/page/manager/clinic/inventory/inventory/Inventory"),
      hidden: true,
      props: true
    }, {
      name: "statement",
      meta: { title: "库存流水", icon: "dashboard" },
      path: "/business/manager/clinic/inventory/inventory/statement/:viewMode/:mode",
      component: () => import("@/views/business/page/manager/clinic/inventory/inventory/Statement"),
      hidden: true,
      props: true
    }, {
      name: "retail_ord",
      meta: { title: "零售单", icon: "dashboard" },
      path: "/business/manager/clinic/inventory/retail/retail_ord/:viewMode/:mode",
      component: () => import("@/views/business/page/manager/clinic/inventory/retail/RetailOrd"),
      hidden: true,
      props: true
    }, {
      name: "in_ord",
      meta: { title: "入库单", icon: "dashboard" },
      path: "/business/manager/clinic/inventory/change/in_ord/:viewMode/:mode",
      component: () => import("@/views/business/page/manager/clinic/inventory/change/InOrd"),
      hidden: true,
      props: true
    }, {
      name: "out_ord",
      meta: { title: "出库单", icon: "dashboard" },
      path: "/business/manager/clinic/inventory/change/out_ord/:viewMode/:mode",
      component: () => import("@/views/business/page/manager/clinic/inventory/change/OutOrd"),
      hidden: true,
      props: true
    }, {
      name: "allocation_ord",
      meta: { title: "调拨单", icon: "dashboard" },
      path: "/business/manager/clinic/inventory/allocation/allocation_ord/:viewMode/:mode",
      component: () => import("@/views/business/page/manager/clinic/inventory/allocation/AllocationOrd"),
      hidden: true,
      props: true
    }, {
      name: "check_ord",
      meta: { title: "盘点单", icon: "dashboard" },
      path: "/business/manager/clinic/inventory/check/check_ord/:viewMode/:mode",
      component: () => import("@/views/business/page/manager/clinic/inventory/check/CheckOrd"),
      hidden: true,
      props: true
    }, // ====================  治疗管理  费用管理  ====================
    {
      name: "enroll_fee",
      meta: { title: "挂号费用", icon: "dashboard" },
      path: "/business/manager/clinic/treatment/fee/enroll_fee/:viewMode/:mode",
      component: () => import("@/views/business/page/manager/clinic/treatment/fee/EnrollFee"),
      hidden: true,
      props: true
    }, {
      name: "serve_fee",
      meta: { title: "服务费用", icon: "dashboard" },
      path: "/business/manager/clinic/treatment/fee/serve_fee/:viewMode/:mode",
      component: () => import("@/views/business/page/manager/clinic/treatment/fee/ServeFee"),
      hidden: true,
      props: true
    }, {
      name: "patient",
      meta: { title: "患者信息", icon: "dashboard" },
      path: "/business/manager/clinic/treatment/patient/patient/:viewMode/:mode",
      component: () => import("@/views/business/page/manager/clinic/treatment/patient/Patient"),
      hidden: true,
      props: true
    }, {
      name: "std_prescription",
      meta: { title: "标准处方", icon: "dashboard" },
      path: "/business/manager/clinic/treatment/std_prescription/std_prescription/:viewMode/:mode",
      component: () => import("@/views/business/page/manager/clinic/treatment/stdprescription/StdPrescription"),
      hidden: true,
      props: true
    }, {
      name: "diag_record",
      meta: { title: "就诊记录", icon: "dashboard" },
      path: "/business/manager/clinic/treatment/treatment/diag_record/:viewMode/:mode",
      component: () => import("@/views/business/page/manager/clinic/treatment/treatment/DiagRecord"),
      hidden: true,
      props: true
    }, {
      name: "enroll_record",
      meta: { title: "挂号记录", icon: "dashboard" },
      path: "/business/manager/clinic/treatment/treatment/enroll_record/:viewMode/:mode",
      component: () => import("@/views/business/page/manager/clinic/treatment/treatment/EnrollRecord"),
      hidden: true,
      props: true
    }, {
      name: "treatment_record",
      meta: { title: "诊疗记录", icon: "dashboard" },
      path: "/business/manager/clinic/treatment/treatment/treatment_record/:viewMode/:mode",
      component: () => import("@/views/business/page/manager/clinic/treatment/treatment/TreatmentRecord"),
      hidden: true,
      props: true
    }, {
      name: "med_prescription",
      meta: { title: "成药处方", icon: "dashboard" },
      path: "/business/manager/clinic/treatment/treatment/med_prescription/:viewMode/:mode",
      component: () => import("@/views/business/page/manager/clinic/treatment/treatment/MedPrescription"),
      hidden: true,
      props: true
    }, {
      name: "chmed_prescription",
      meta: { title: "饮片处方", icon: "dashboard" },
      path: "/business/manager/clinic/treatment/treatment/chmed_prescription/:viewMode/:mode",
      component: () => import("@/views/business/page/manager/clinic/treatment/treatment/ChmedPrescription"),
      hidden: true,
      props: true
    }, {
      name: "serve_prescription",
      meta: { title: "理疗安排", icon: "dashboard" },
      path: "/business/manager/clinic/treatment/treatment/serve_prescription/:viewMode/:mode",
      component: () => import("@/views/business/page/manager/clinic/treatment/treatment/ServePrescription"),
      hidden: true,
      props: true
    }]
} // ====================  大屏看板界面  ====================

  // 404页，*统配，必须设置在最后
  // { path: "*", redirect: "/404", hidden: true }
]

const createRouter = () => new Router({
  scrollBehavior: () => ({ y: 0 }), routes: constantRoutes
})

// 创建路由
const router = createRouter()

// 重设路由
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}

export default router
